翻訳と辞書
Words near each other
・ Servando Bayo
・ Servando Cabrera Moreno
・ Servando Carrasco
・ Servando Chávez Hernández
・ Servando González
・ Servando Gómez Martínez
・ Servando Nicolás Villamil
・ Servando Ruiz-Gómez y González-Llanos
・ Servando Sánchez
・ Servando Teresa de Mier
・ Servandus and Cermanus
・ Servani
・ Servanin
・ Servant (band)
・ Servant (CORBA)
Servant (design pattern)
・ Servant (disambiguation)
・ Servant Air
・ Servant Girl Annihilator
・ Servant in the Place of Truth
・ Servant leadership
・ Servant mouse
・ Servant of God
・ Servant of Love
・ Servant of the Bones
・ Servant of the Dragon
・ Servant of the Empire
・ Servant of the servants of God
・ Servant of the Shard
・ Servant of Two Masters


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Servant (design pattern) : ウィキペディア英語版
Servant (design pattern)

Servant is a design pattern used to offer some functionality to a group of classes without defining that functionality in each of them. A Servant is a class whose instance (or even just class) provides methods that take care of a desired service, while objects for which (or with whom) the servant does something, are taken as parameters.
== Description and simple example ==

Servant is used for providing some behavior to a group of classes. Instead of defining that behavior in each class - or when we cannot factor out this behavior in the common parent class - it is defined once in the Servant.
For example: we have a few classes representing geometric objects (rectangle, ellipse, and triangle). We can draw these objects on some canvas. When we need to provide a “move” method for these objects we could implement this method in each class, or we can define an interface they implement and then offer the “move” functionality in a servant. An interface is defined to ensure that serviced classes have methods, that servant needs to provide desired behavior. If we continue in our example, we define an Interface “Movable” specifying that every class implementing this interface needs to implement method “getPosition” and “setPosition”. The first method gets the position of an object on a canvas and second one sets the position of an object and draws it on a canvas. Then we define a servant class “MoveServant”, which has two methods “moveTo(Movable movedObject, Position where)” and moveBy(Movable movedObject, int dx, int dy). The Servant class can now be used to move every object which implements the Movable. Thus the “moving” code appears in only one class which respects the “Separation of Concerns” rule.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Servant (design pattern)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.